<template>
  <div class="xtx-bread-item">
      <!-- 判断当前是否是可跳转的链接 -->
    <router-link v-if="to" :to="to"><slot /></router-link>
    <span v-else>
      <!-- 放置面包屑中的每一项的内容 -->
      <slot />
    </span>
    <i v-if="separator">{{ separator }}</i>
    <i v-else class="iconfont icon-angle-right"></i>
  </div>
</template>

<script>
import { inject } from 'vue'
export default {
  name: 'XtxBreadItem',
  props: {
    to: {
      type: String,
      default: ''
    }
  },
  setup () {
    const separator = inject('separator')
    return { separator }
  }
}
</script>
